package com.itheima;

import com.itheima.service.BookService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class App {
        public static void main(String[] args) {
            //1.创建IoC容器对象，加载spring核心配置文件
            ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
            //2 从IOC容器中获取Bean对象(BookService对象)
            BookService bookService= (BookService)ctx.getBean("bookService2");
            BookService bookService3 = (BookService) ctx.getBean("bookService3");
            //3 调用Bean对象(BookService对象)的方法
            System.out.println(bookService);  /*com.itheima.service.impl.BookServiceImpl@25bbe1b6
               (因为设置的范围是singleton)  单列的*/
            System.out.println(bookService3); /*com.itheima.service.impl.BookServiceImpl@25bbe1b6*/
            bookService.save();
        }

}
